<?php
/**
 * @file test009.php
 * @package test
 * @subpackage 
 * @version $id: 0.1 utf8 Sun Nov  1 22:53:59 CST 2009 $
 * @author LD King <kldscs@gmail.com>
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 * @desc
 *   测试 PHP 中 PDO 实现事务处理的可行性;(MyISAM 引擎)
 *   事实证明: MyISAM 使用rollBack 是不行的
 */
$dsn = "mysql:host=localhost;dbname=test;unix_socket=/tmp/mysql.sock";
//$dsn = "mysql://root:shadow@localhost/test";

echo "someting happend.<br />";
$dbh = new PDO($dsn,'mifunny','',
        array( PDO::ATTR_PERSISTENT => false));

try{
//throw new PDOException("XXOO!",444);

    $dbh->beginTransaction();

    $dbh->exec("insert into test1 values ('2', 'bbq2')");
  echo "PDO::errorCode() - ".$dbh->errorCode();



    $dbh->exec("insert into test2 values ('2', 'bbq2')");
  echo "PDO::errorCode() - ".$dbh->errorCode();
  
    echo "I'm OK!";
   var_dump($dbh->errorInfo());
    $dbh->commit();
//    $dbh->rollBack();

}catch(PDOException $e){
    echo "Fuck SSS - ".$e->getMessage();
    $dbh->rollBack();
}


?>

